<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ include file="/page/base.jsp"%>
<%@ taglib prefix="d" uri="/doone-comm-ui-tags"%>


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
	<head>
	    <base href="<%=basePath%>"></base>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
		<title></title>
		<!-- Libraries -->
		<link type="text/css" href="<%=path %>/manage/css/layout.css" rel="stylesheet" />
		<link type="text/css" href="<%=path%>/manage/css/new_style.css" rel="stylesheet" />
		<link rel="stylesheet" type="text/css"	href="<%=path%>/manage/css/Tooltip.css" />
		<script type="text/javascript" src="<%=path %>/manage/js/jquery-1.4.4.min.js"></script>
		<script type="text/javascript" src="<%=path %>/manage/js/easyTooltip.js"></script>
		<script type="text/javascript" src="<%=path %>/manage/js/jquery-ui-1.8.11.custom.min.js"></script>
		<script type="text/javascript" src="<%=path %>/manage/js/jquery.wysiwyg.js"></script>
		<script type="text/javascript" src="<%=path %>/manage/js/hoverIntent.js"></script>
		<script type="text/javascript" src="<%=path %>/manage/js/superfish.js"></script>
		<script type="text/javascript" src="<%=path %>/manage/js/custom.js"></script>
		<script type="text/javascript" src="<%=path %>/manage/js/My97DatePicker/WdatePicker.js"></script>
		<%-- 验证js Start --%>
		<script type="text/javascript" src="<%=path%>/manage/js/Tooltip.js"></script>
		<script type="text/javascript"
			src="<%=path%>/manage/js/jquery.validate.min.js"></script>
		<script type="text/javascript"
			src="<%=path%>/manage/js/jquery.validate.methods.min.js"></script>
		<script type="text/javascript"
			src="<%=path%>/manage/js/jquery.validate.defaults.js"></script>
			<script type="text/javascript" src="<%=path%>/manage/js/errorTip.js"></script>
		<sx:head />
		<script language="javascript" type="text/javascript">
function openMessage(mesId) {
	    //应用编辑
			$.ajax({
				url : root+'/message/getMessage.action',
				method : 'post',
				dataType : 'json',
				data:{'mesId' : mesId},
				success : function(data) {
				      $("#intPushMsgId").attr("value",data.intPushMsgId);
				      $("#intPushMsgType").attr("value",data.intPushMsgType);
				      $("#intPushMsgStatue").attr("value",data.intPushMsgStatue);
				      $("#varPushMsgName").attr("value",data.varPushMsgName);
				      $("#varPushMsgDescrip").attr("value",data.varPushMsgDescrip);
				      $("#varPushMsgContent").attr("value",data.varPushMsgContent);
				      $("#intPushMsgStatue").attr("value",data.intPushMsgStatue);
				      $("#datDatPushMsgDatetime").attr("value",data.datDatPushMsgDatetime);
				      $("#datPushMsgEndDatetime").attr("value",data.datPushMsgEndDatetime);
					  $("#openMessageDialog").dialog("open");
				},
				error:function(err){
					if(err.responseText!='')
						alert(err.responseText);
					else
						alert("请求失败！");
				}
			});
			
		
	}
$(document).ready(function() {

		//加载消息编辑dialog
		$("#openMessageDialog").dialog({
			autoOpen : false,
			width : 500,
			height :400,
			modal : true,
			title : '消息编辑',
			buttons : {
				"保存" : function() {
				if(!editMessageForm.valid()){
				alert("数据有误，请正确填写数据");
				}else{
				    $("#editMessageForm").submit();
					$(this).dialog("close");
					}
				},
				"取消" : function() {
					$(this).dialog("close");
					$("#editMessageForm")[0].reset();
				}
			},
			close : function() {
				$("#editMessageForm")[0].reset();
			}
		});
		//消息添加
		$("#addMessageDialog").dialog({
			autoOpen : false,
			width : 500,
			height : 400,
			modal : true,
			title : '消息添加',
			buttons : {
				"保存" : function() {
				if(!addMessageForm.valid()){
				alert("数据有误，请正确填写数据");
				}else{
				    $("#addMessageForm").submit();
					$(this).dialog("close");
					}
				},
				"取消" : function() {
					$(this).dialog("close");
					$("#addMessageForm")[0].reset();
				}
			},
			close : function() {
				$("#addMessageForm")[0].reset();
			}
		});
		
		 var editMessageForm = $("#editMessageForm").validate({ 	       
		        rules : {
		           "messageInfo.varPushMsgName" : {
		          	  required : true
		            },
		            "messageInfo.intPushMsgType":{
		             required : true
		            },
		             "messageInfo.varPushMsgContent":{
		             required : true
		            },
		             "messageInfo.intPushMsgStatue":{
		             required : true
		            },
		             "messageInfo.datDatPushMsgDatetime":{
		             required : true
		            },
		             "messageInfo.datPushMsgEndDatetime":{
		             required : true
		            },
		              "messageInfo.varPushMsgDescrip" : {
		                required : true		              
		            }		           
		        },
		        messages : {
		              "messageInfo.varPushMsgName" : {
		          	  required : "请输入消息名称"
		            },
		            "messageInfo.intPushMsgType":{
		             required : "请选择消息类型"
		            },
		             "messageInfo.varPushMsgContent":{
		             required : "请输入消息内容"
		            },
		             "messageInfo.intPushMsgStatue":{
		             required : "请选择消息状态"
		            },
		             "messageInfo.datDatPushMsgDatetime":{
		             required : "请选择消息发布时间"
		            },
		             "messageInfo.datPushMsgEndDatetime":{
		             required : "请选择消息失效时间"
		            },
		              "messageInfo.varPushMsgDescrip" : {
		                required : "请输入消息简介"		              
		            }		               
		        }
		    });
		    
		    var addMessageForm = $("#addMessageForm").validate({ 	       
		        rules : {
		           "pushmessageInfo.varPushMsgName" : {
		          	  required : true
		            },
		            "pushmessageInfo.intPushMsgType":{
		             required : true
		            },
		             "pushmessageInfo.varPushMsgContent":{
		             required : true
		            },
		             "pushmessageInfo.intPushMsgStatue":{
		             required : true
		            },
		             "pushmessageInfo.datDatPushMsgDatetime":{
		             required : true
		            },
		             "pushmessageInfo.datPushMsgEndDatetime":{
		             required : true
		            },
		              "pushmessageInfo.varPushMsgDescrip" : {
		                required : true		              
		            }		           
		        },
		        messages : {
		              "pushmessageInfo.varPushMsgName" : {
		          	  required : "请输入消息名称"
		            },
		            "pushmessageInfo.intPushMsgType":{
		             required : "请选择消息类型"
		            },
		             "pushmessageInfo.varPushMsgContent":{
		             required : "请输入消息内容"
		            },
		             "pushmessageInfo.intPushMsgStatue":{
		             required : "请选择消息状态"
		            },
		             "pushmessageInfo.datDatPushMsgDatetime":{
		             required : "请选择消息发布时间"
		            },
		             "pushmessageInfo.datPushMsgEndDatetime":{
		             required : "请选择消息失效时间"
		            },
		             "pushmessageInfo.varPushMsgDescrip" : {
		            required : "请输入消息简介"		              
		            }		               
		        }
		    });
		    

	});
//添加消息	
function openAdd(){
			$( "#addMessageDialog" ).dialog("open");
		}
</script>

	</head>

	<body>
		
					<div >
				<p class="sitemap">当前位置：内容管理 > 推送内容管理</p>
                <h1>消息推送内容</h1>
					<div >
					
						<!-- Tabs -->
						<div id="tabs">
							<ul>
								<li><a href="#tabs-1">推送内容列表</a></li>
								
							</ul>
							
							<!-- First tab -->
					              <table cellspacing="0" cellpadding="0" border="0" class="fullwidth">
                                              <thead>
                                                <tr>
                                                  <td width="150px;">名称</td>
                                                  <td>简介</td>
                                                  <td>消息类容</td>
                                                  <td>消息类型</td>
                                                  <td>消息状态</td>                                                  
                                                  <td>推送时间</td>
                                                  <td>失效时间</td>
                                                  <td>操作</td>
                                                </tr>
                                              </thead>
                                              <tbody>
                                              <s:iterator value="messagelist">
                                                <tr class="odd">
                                                  <td><s:property value="varPushMsgName"/></td>
                                                  <td><s:property value="varPushMsgDescrip"/></td>
                                                  <td><s:property value="varPushMsgContent"/></td>
                                                  <td><s:property value="varPushMsgTypeName"/></td>
                                                  <td><s:property value="varPushMsgStatueName"/></td>   
                                                  <td><s:property value="datDatPushMsgDatetime"/></td>
                                                  <td><s:property value="datPushMsgEndDatetime"/></td>
                                                  
                                                  <td>
                                                 
                                                  <a  class="icon icon_edit" title="编辑 "  href="javascript:openMessage('<s:property value="intPushMsgId" />')"></a>
												  <a class="icon icon_delete" title="删除"  href="<%=path %>/message/delMessage.action?mesId=<s:property value="intPushMsgId" />"></a>
								</td>
                                                </tr>
                                               </s:iterator> 
                                               <tr>
                                               <td colspan="2">

                         <!-- <input type="button" value="添加" class="button" onClick="">-->
                          <a href="javascript:openAdd()" class="btn_addnew">添加</a>
                                               </td>
                                               </tr>
                                              </tbody>
                                          </table>
							<!-- End of Tabs -->
						</div>
					<!-- 分页标签开始 -->
				<div align="right" style="float: right;">
					<d:page id="page" template="details" skin="gray">
					</d:page>
				</div>
				<!-- 分页标签结束 -->	
						<hr />
					</div>
				</div>
				
				
			
		<!-- 编辑页使用的弹出层 -->
		<div id="openMessageDialog" style="display: none;">
			<form action="<%=path%>/message/editMessage.action"
							method="post" id="editMessageForm">
							<input type="hidden" name="messageInfo.intPushMsgId" id="intPushMsgId">
							<table class="fullwidth" cellpadding="0" cellspacing="0"
								border="0">
								<tr>
									<td>
										消息名称
									</td>
									<td>									   
										<input type="text" name="messageInfo.varPushMsgName" id="varPushMsgName">
										<span style="color: red">*</span>
									</td>
								</tr>
								<tr>
									<td>
										消息类型
									</td>
									<td>
									<s:radio list="msgTypeMap" listKey="key" listValue="value" name="messageInfo.intPushMsgType" id="intPushMsgType" ></s:radio>
										
										<span style="color: red">*</span>
									</td>
								</tr>
								<tr>
									<td>
										消息简介
									</td>
									<td>
									    <input type="text" name="messageInfo.varPushMsgDescrip" id="varPushMsgDescrip">
										<span style="color: red">*</span>
									</td>
								</tr>
								<tr>
									<td>
										消息内容
									</td>
									<td>									   
										<input type="text" name="messageInfo.varPushMsgContent" id="varPushMsgContent">
										<span style="color: red">*</span>
									</td>
								</tr>
								<tr>
									<td>
										消息状态
									</td>
									<td>		
										<s:radio list="msgStatusMap" listKey="key" listValue="value" name="messageInfo.intPushMsgStatue" id="intPushMsgStatue" ></s:radio>
										<span style="color: red">*</span>
									</td>
								</tr>
								<tr>
									<td>
										推送时间
									</td>
									<td>									   
										<input type="text" name="messageInfo.datDatPushMsgDatetime" id="datDatPushMsgDatetime" onClick="WdatePicker({startDate:'%y-%M-01 00:00:00',dateFmt:'yyyy-MM-dd HH:mm:ss',alwaysUseStartDate:true})">
										<span style="color: red">*</span>
									</td>
								</tr>
								<tr>
									<td>
										推送失效时间
									</td>
									<td>									   
										<input type="text" name="messageInfo.datPushMsgEndDatetime" id="datPushMsgEndDatetime" onClick="WdatePicker({startDate:'%y-%M-01 00:00:00',dateFmt:'yyyy-MM-dd HH:mm:ss',alwaysUseStartDate:true})">
										<span style="color: red">*</span>
									</td>
								</tr>
							</table>

						</form>
					</div>
		<!-- 编辑页使用的弹出层 -->
		<div id="addMessageDialog" style="display: none;">
			<form action="<%=path%>/message/addMessage.action"
							method="post" id="addMessageForm">
							<table class="fullwidth" cellpadding="0" cellspacing="0"
								border="0">
								<tr>
									<td>
										消息名称
									</td>
									<td>									   
										<input type="text" name="pushmessageInfo.varPushMsgName" id="pushvarPushMsgName">
										<span style="color: red">*</span>
									</td>
								</tr>
								<tr>
									<td>
										消息类型
									</td>
									<td>
									<s:radio list="msgTypeMap" listKey="key" listValue="value" name="pushmessageInfo.intPushMsgType" id="pushintPushMsgType" cssClass="textbox_border"></s:radio>
									   <span style="color: red">*</span>
									</td>
								</tr>
								<tr>
									<td>
										消息简介
									</td>
									<td>
									    <input type="text" name="pushmessageInfo.varPushMsgDescrip" id="pushvarPushMsgDescrip">
										<span style="color: red">*</span>
									</td>
								</tr>
								<tr>
									<td>
										消息内容
									</td>
									<td>									   
										<input type="text" name="pushmessageInfo.varPushMsgContent" id="pushvarPushMsgContent">
										<span style="color: red">*</span>
									</td>
								</tr>
								<tr>
									<td>
										消息状态
									</td>
									<td>
									<s:radio list="msgStatusMap" listKey="key" listValue="value" name="pushmessageInfo.intPushMsgStatue" id="pushintPushMsgStatue" cssClass="textbox_border"></s:radio>									   
									
										<span style="color: red">*</span>
									</td>
								</tr>
								<tr>
									<td>
										推送时间
									</td>
									<td>									   
										<input type="text" name="pushmessageInfo.datDatPushMsgDatetime" id="pushdatDatPushMsgDatetime" onClick="WdatePicker({startDate:'%y-%M-01 00:00:00',dateFmt:'yyyy-MM-dd HH:mm:ss',alwaysUseStartDate:true})">
										<span style="color: red">*</span>
									</td>
								</tr>
								<tr>
									<td>
										推送失效时间
									</td>
									<td>									   
										<input type="text" name="pushmessageInfo.datPushMsgEndDatetime" id="pushdatPushMsgEndDatetime" onClick="WdatePicker({startDate:'%y-%M-01 00:00:00',dateFmt:'yyyy-MM-dd HH:mm:ss',alwaysUseStartDate:true})">
										<span style="color: red">*</span>
									</td>
								</tr>
							</table>

						</form>
					</div>
	</body>
</html>
